package com.gaussian.property.admin.module.biz.vo.checktable;

import com.songqi.common.core.validationgroup.EditGroup;
import com.songqi.common.core.validator.NumberRegex;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;

/**
 * @description:
 * @author: songqi(13776346982)
 * @date: 2024/4/11 21:06
 */
@Data
@ApiModel("新增稽核表(稽核标准)")
public class CheckTableVo {

    @NotBlank(message = "稽核表ID不能为空", groups = EditGroup.class)
    private String checkTableId;

    @ApiModelProperty("标准名称")
    @NotBlank(message = "不能为空")
    private String checkName;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("稽核模块")
    @NotEmpty(message = "稽核模块列表不能为空")
    @Valid
    private List<CheckModuleVo> checkModuleVoList;

    @Data
    public static class CheckModuleVo {

        @ApiModelProperty("模块ID")
        private String checkModuleId;
        /**
         * 模块名称
         */
        @ApiModelProperty("模块名称")
        @NotBlank(message = "模块名称不能为空")
        private String moduleName;


        @ApiModelProperty("模块分值")
        @NotNull(message = "模块分值不能为空")
        @NumberRegex(regex = "^(100(\\.0)?|(\\d{1,2})(\\.0)?)$", message = "模块分值0-100之间整数")
        private Double score;

        @ApiModelProperty("是否允许加分。1-允许。0-不允许")
        @NotNull(message = "是否必传附件")
        @Max(value = 1, message = "是否允许加分只允许0和1")
        @Min(value = 0, message = "是否允许加分只允许0和1")
        private Integer isAllowAddScore;

        @ApiModelProperty("是否必传附件。1-是。0-否")
        @NotNull(message = "是否必传附件必填")
        @Max(value = 1, message = "是否必传附件只允许0和1")
        @Min(value = 0, message = "是否必传附件只允许0和1")
        private Integer isAllowAttach;

        @ApiModelProperty("排序号")
        @NotNull(message = "排序号必传")
        @Min(value = 1, message = "排序号只允许1和100")
        @Max(value = 100, message = "排序号只允许1和100")
        private Integer sortNum;

        @ApiModelProperty("指标")
        @NotEmpty(message = "指标列表不能为空")
        @Valid
        private List<CheckCriteriaVo> checkCriteriaVoList;
    }


    @Data
    public static class CheckCriteriaVo {

        @ApiModelProperty("指标ID")
        private String checkCriteriaId;

        /**
         * 指标名称
         */
        @ApiModelProperty("指标名称")
        private String criteriaName;

        /**
         * 指标分值，可为空
         */
        @ApiModelProperty("指标分值")
        @NumberRegex(regex = "^100(\\.0)?$|^\\d{1,2}(\\.\\d)?$", message = "指标分值0-100之间，允许一位小数")
        private Double score;

        @ApiModelProperty("排序号")
        @NotNull(message = "排序号必传")
        @Min(value = 1, message = "排序号只允许1和100")
        @Max(value = 100, message = "排序号只允许1和100")
        private Integer sortNum;

        @ApiModelProperty("标准")
        @Valid
        private List<CheckStandardVo> checkStandardVoList;
    }



    @Data
    public static class CheckStandardVo {

        @ApiModelProperty("标准id")
        private String checkStandardId;

        /**
         * 标准名称
         */
        @ApiModelProperty("标准名称")
        @NotBlank(message = "标准作业名称必填")
        private String standardName;

        /**
         * 标准分值，可为空
         */
        @ApiModelProperty("标准分值")
        @NumberRegex(regex = "^100(\\.0)?$|^\\d{1,2}(\\.\\d)?$", message = "标准分值0-100之间，允许一位小数")
        private Double score;

        /**
         * 扣分项
         */
        @ApiModelProperty("扣分项")
        private String deductionItem;

        @ApiModelProperty("排序号")
        @NotNull(message = "排序号必传")
        @Min(value = 1, message = "排序号只允许1和100")
        @Max(value = 100, message = "排序号只允许1和100")
        private Integer sortNum;

    }

}
